#include "paopaotang.h"
#include "ui_paopaotang.h"
#include <QPainter>
#include<QTimer>
#include<QKeyEvent>
#include<QtGlobal>

paopaotang::paopaotang(QWidget *parent)
    : QMainWindow(parent), blsRun(false)
    , ui(new Ui::paopaotang)
{
    ui->setupUi(this);
    this->setGeometry(QRect(300,30,760,760));
}

paopaotang::~paopaotang()
{
    delete ui;
}
void paopaotang::paintEvent(QPaintEvent* event) {
    QPainter painter(this);
    if (!blsRun)
    {
        Initperson1();
        Initperson2();
    }
    Initobb();
    painter.setPen(Qt::black);//设置画笔颜色
    painter.setBrush(Qt::gray);//设置填充颜色
    painter.drawRect(10, 10, 740, 740);
    painter.setPen(Qt::black);//设置画笔颜色
    painter.setBrush(Qt::white);//设置填充颜色
    painter.drawRect(20, 20, 720, 720);//前两个表示离框多少距离，后两个表示框的长宽
    painter.drawPixmap(20, 20, 720, 720, QPixmap("://dlll/dx/bj.png"));
    painter.setPen(Qt::black);
    painter.setBrush(Qt::green);
    painter.drawRect(vperson1);
    painter.drawPixmap(vperson1, QPixmap("://dlll/dx/dxx.png"));
    painter.setPen(Qt::black);
    painter.setBrush(Qt::green);
    painter.drawRect(vperson2);
    painter.drawPixmap(vperson2, QPixmap("://dlll/dx/ph.png"));
    for (int i = 0; i < 3; i++) {
        if (cz1[i]) {
            painter.setPen(Qt::black);
            painter.setBrush(Qt::black);
            painter.drawRect(boom[i]);
            painter.drawPixmap(boom[i], QPixmap("://dlll/dx/zd.png"));
        }
        if (cz2[i]) {
            painter.setPen(Qt::black);
            painter.setBrush(Qt::black);
            painter.drawRect(boom1[i]);
            painter.drawPixmap(boom1[i], QPixmap("://dlll/dx/zd.png"));
        }
    }
    QFont font1("Courier", 30);//字体和字号
    painter.setFont(font1);
    painter.setPen(Qt::black);
    painter.setBrush(Qt::black);
    painter.drawText(230,100,Display);
    painter.setPen(Qt::black);
    painter.setBrush(Qt::black);
    painter.drawRects(&Ob1[0], Ob1.size());
    painter.drawRects(&Ob2[0], Ob2.size());
    painter.drawRects(&Ob3[0], Ob3.size());
    painter.drawRects(&Ob4[0], Ob4.size());
    painter.drawRects(&Ob5[0], Ob5.size());
    painter.drawRects(&Ob6[0], Ob6.size());
    painter.drawRects(&Ob7[0], Ob7.size());
    painter.drawRects(&Ob8[0], Ob8.size());
    painter.drawRects(&Ob9[0], Ob9.size());
    painter.drawRects(&Ob10[0], Ob10.size());
    painter.drawRects(&Ob11[0], Ob11.size());
    painter.drawRects(&Ob12[0], Ob12.size());
    painter.drawRects(&Ob13[0], Ob13.size());
    painter.drawRects(&Ob14[0], Ob14.size());
    painter.drawRects(&Ob15[0], Ob15.size());
    if (h) {
        painter.setPen(Qt::black);
        painter.setBrush(Qt::black);
        painter.drawRect(tx1);
        painter.drawRect(tx2);
        painter.drawPixmap(tx1, QPixmap("://dlll/dx/bz.png"));
        painter.drawPixmap(tx2, QPixmap("://dlll/dx/bz.png"));
    }
    if (i) {
        painter.setPen(Qt::black);
        painter.setBrush(Qt::black);
        painter.drawRect(tx3);
        painter.drawRect(tx4);
        painter.drawPixmap(tx3, QPixmap("://dlll/dx/bz.png"));
        painter.drawPixmap(tx4, QPixmap("://dlll/dx/bz.png"));
    }
    if (j) {
        painter.setPen(Qt::black);
        painter.setBrush(Qt::black);
        painter.drawRect(tx5);
        painter.drawRect(tx6);
        painter.drawPixmap(tx5, QPixmap("://dlll/dx/bz.png"));
        painter.drawPixmap(tx6, QPixmap("://dlll/dx/bz.png"));
    }
    if (k) {
        painter.setPen(Qt::black);
        painter.setBrush(Qt::black);
        painter.drawRect(tx7);
        painter.drawRect(tx8);
        painter.drawPixmap(tx7, QPixmap("://dlll/dx/bz.png"));
        painter.drawPixmap(tx8, QPixmap("://dlll/dx/bz.png"));
    }
    if (l) {
        painter.setPen(Qt::black);
        painter.setBrush(Qt::black);
        painter.drawRect(tx9);
        painter.drawRect(tx10);
        painter.drawPixmap(tx9, QPixmap("://dlll/dx/bz.png"));
        painter.drawPixmap(tx10, QPixmap("://dlll/dx/bz.png"));
    }
    if (o) {
        painter.setPen(Qt::black);
        painter.setBrush(Qt::black);
        painter.drawRect(tx11);
        painter.drawRect(tx12);
        painter.drawPixmap(tx11, QPixmap("://dlll/dx/bz.png"));
        painter.drawPixmap(tx12, QPixmap("://dlll/dx/bz.png"));
    }
    for (int m = 0; m < Ob1.size(); m++)
    {
        painter.drawPixmap(Ob1[m], QPixmap("://dlll/dx/dl5.png"));
    }
    for (int m = 0; m < Ob2.size(); m++)
    {
        painter.drawPixmap(Ob2[m], QPixmap("://dlll/dx/dl3.png"));
        painter.drawPixmap(Ob3[m], QPixmap("://dlll/dx/dl3.png"));
    }
    for (int m = 0; m < Ob4.size(); m++)
    {
        painter.drawPixmap(Ob4[m], QPixmap("://dlll/dx/dl2.png"));
        painter.drawPixmap(Ob5[m], QPixmap("://dlll/dx/dl2.png"));
    }
    for (int m = 0; m < Ob6.size(); m++)
    {
        painter.drawPixmap(Ob6[m], QPixmap("://dlll/dx/dl1.png"));
        painter.drawPixmap(Ob7[m], QPixmap("://dlll/dx/dl1.png"));
    }
    for (int m = 0; m < Ob8.size(); m++)
    {
        painter.drawPixmap(Ob8[m], QPixmap("://dlll/dx/dl4.png"));
        painter.drawPixmap(Ob9[m], QPixmap("://dlll/dx/dl4.png"));
        painter.drawPixmap(Ob10[m], QPixmap("://dlll/dx/dl4.png"));
        painter.drawPixmap(Ob11[m], QPixmap("://dlll/dx/dl4.png"));
        painter.drawPixmap(Ob12[m], QPixmap("://dlll/dx/dl4.png"));
        painter.drawPixmap(Ob13[m], QPixmap("://dlll/dx/dl4.png"));
        painter.drawPixmap(Ob14[m], QPixmap("://dlll/dx/dl4.png"));
        painter.drawPixmap(Ob15[m], QPixmap("://dlll/dx/dl4.png"));
    }
    if (blsover) {
        sj->stop();
        sjj->stop();
        sj1->stop();
        sj2->stop();
        sj3->stop();
        sj4->stop();
        sj5->stop();
        sj6->stop();
        sjs1->stop();
        sjs2->stop();
        sjs3->stop();
        sjs4->stop();
        sjs5->stop();
        sjs6->stop();
    }
}
void paopaotang::Initperson1() {
    blsRun = true;
    blsover = false;
    h = false;
    i = false;
    j = false;
    k = false;
    l = false;
    o = false;
    for (int i = 0; i < 3; i++)
    {
        cz1[i] = false;
        cz2[i] = false;
        a[i] = b[i] = true;
    }
    QRect rect(20, 720, 20, 20);
    vperson1 = rect;
    sj = new QTimer(this);
    sj->start(50);
    connect(sj, SIGNAL(timeout()), SLOT(uupdate()));
    sjj = new QTimer(this);
    sjj->start(2500);
    connect(sjj, SIGNAL(timeout()), SLOT(chucun()));
    sj1 = new QTimer(this);
    connect(sj1, SIGNAL(timeout()), SLOT(disapp1()));
    sj2 = new QTimer(this);
    connect(sj2, SIGNAL(timeout()), SLOT(disapp2()));
    sj3 = new QTimer(this);
    connect(sj3, SIGNAL(timeout()), SLOT(disapp3()));
    sj4 = new QTimer(this);
    connect(sj4, SIGNAL(timeout()), SLOT(disapp4()));
    sj5 = new QTimer(this);
    connect(sj5, SIGNAL(timeout()), SLOT(disapp5()));
    sj6 = new QTimer(this);
    connect(sj6, SIGNAL(timeout()), SLOT(disapp6()));
    sjs1 = new QTimer(this);
    connect(sjs1, SIGNAL(timeout()), SLOT(zharen1()));
    sjs2 = new QTimer(this);
    connect(sjs2, SIGNAL(timeout()), SLOT(zharen2()));
    sjs3 = new QTimer(this);
    connect(sjs3, SIGNAL(timeout()), SLOT(zharen3()));
    sjs4 = new QTimer(this);
    connect(sjs4, SIGNAL(timeout()), SLOT(zharen4()));
    sjs5 = new QTimer(this);
    connect(sjs5, SIGNAL(timeout()), SLOT(zharen5()));
    sjs6 = new QTimer(this);
    connect(sjs6, SIGNAL(timeout()), SLOT(zharen6()));
    //各种初始化
}
void paopaotang::Initperson2() {
    QRect rect(720, 20, 20, 20);
    vperson2 = rect;//人物2初始化
}
void paopaotang::Initboom1() {
    for (int i = 0; i < 3; i++)
    {
        if (a[i])
        {
            QRect rect(vperson1.left(), vperson1.top(), 20, 20);
            boom[i] = rect;
            a[i] = false;
            cz1[i] = true;
            if (i == 0) {
                QRect rect2(20, boom[0].top(), 720, 20);
                tx2 = rect2;
                QRect rect1(boom[0].left() , 20, 20, 720);
                tx1 = rect1;
                sjs1->start(1000);
                sj1->start(2000);
            }
            else if (i == 1) {
                QRect rect3(20, boom[1].top(), 720, 20);
                tx3 = rect3;
                QRect rect4(boom[1].left(), 20, 20, 720);
                tx4 = rect4;
                sjs2->start(1000);
                sj2->start(2000);
            }
            else if (i == 2) {
                QRect rect5(20, boom[2].top() , 720, 20);
                tx5 = rect5;
                QRect rect6(boom[2].left() , 20, 20, 720);
                tx6 = rect6;
                sjs3->start(1000);
                sj3->start(2000);
            }
            break;
        }
    }
}//人物1释放炸弹
void paopaotang::Initboom2() {
    for (int i = 0; i < 3; i++)
    {
        if (b[i])
        {
            QRect rect(vperson2.left(), vperson2.top(), 20, 20);
            boom1[i] = rect;
            b[i] = false;
            cz2[i] = true;
            if (i == 0) {
                QRect rect7(20, boom1[0].top() , 720, 20);
                tx7 = rect7;
                QRect rect8(boom1[0].left(), 20, 20, 720);
                tx8 = rect8;
                sjs4->start(1000);
                sj4->start(2000);
            }
            else if (i == 1) {
                QRect rect9(20, boom1[1].top() , 720, 20);
                tx9 = rect9;
                QRect rect10(boom1[1].left() , 20, 20, 720);
                tx10 = rect10;
                sjs5->start(1000);
                sj5->start(2000);
            }
            else if (i == 2) {
                QRect rect11(20, boom1[2].top() , 720, 20);
                tx11 = rect11;
                QRect rect12(boom1[2].left() , 20, 20, 720);
                tx12 = rect12;
                sjs6->start(1000);
                sj6->start(2000);
            }
            break;
        }
    }
}//人物2释放炸弹
void paopaotang::chucun() {
    for (int i = 0; i < 3; i++)
    {
        if (!a[i]) {
            a[i] = true;
            break;
        }
    }
    for (int j = 0; j < 3; j++)
    {
        if (!b[j]) {
            b[j] = true;
            break;
        }
    }
}//炸弹空位是否存在
void paopaotang::Initobb() {
    int x = 20, y = 20;
    Ob1.resize(36);
    for (int i = 0; i < Ob1.size(); i++)
    {
        x = 20 + i * 20;
        y = 20 + i * 20;
        QRect rect(x, y, 20, 20);
        Ob1[Ob1.size() - 1 - i] = rect;
    }
    int m = 20, n = 40;
    Ob2.resize(35);
    for (int i = 0; i < Ob2.size(); i++)
    {
        m = 20 + i * 20;
        n = 40 + i * 20;
        QRect rect(m, n, 20, 20);
        Ob2[Ob2.size() - 1 - i] = rect;
    }
    int p = 40, q = 20;
    Ob3.resize(35);
    for (int i = 0; i < Ob3.size(); i++)
    {
        p = 40 + i * 20;
        q = 20 + i * 20;
        QRect rect(p, q, 20, 20);
        Ob3[Ob3.size() - 1 - i] = rect;
    }
    int j = 100, k = 20;
    Ob4.resize(32);
    for (int i = 0; i < Ob4.size(); i++)
    {
        j = 100 + i * 20;
        k = 20 + i * 20;
        QRect rect(j, k, 20, 20);
        Ob4[Ob4.size() - 1 - i] = rect;
    }
    int u = 20, v = 100;
    Ob5.resize(32);
    for (int i = 0; i < Ob5.size(); i++)
    {
        u = 20 + i * 20;
        v = 100 + i * 20;
        QRect rect(u, v, 20, 20);
        Ob5[Ob5.size() - 1 - i] = rect;
    }
    int c = 140, d = 20;
    Ob6.resize(30);
    for (int i = 0; i < Ob6.size(); i++)
    {
        c = 140 + i * 20;
        d = 20 + i * 20;
        QRect rect(c, d, 20, 20);
        Ob6[Ob6.size() - 1 - i] = rect;
    }
    int z = 20, s = 140;
    Ob7.resize(30);
    for (int i = 0; i < Ob7.size(); i++)
    {
        z = 20 + i * 20;
        s = 140 + i * 20;
        QRect rect(z, s, 20, 20);
        Ob7[Ob7.size() - 1 - i] = rect;
    }
    int zz = 80, ss = 460;
    Ob8.resize(10);
    for (int i = 0; i < Ob8.size(); i++)
    {
        zz = 80 + i * 20;
        QRect rect(zz, ss, 20, 20);
        Ob8[Ob8.size() - 1 - i] = rect;
    }
    int mm = 80, nn = 560;
    Ob9.resize(10);
    for (int i = 0; i < Ob9.size(); i++)
    {
        mm = 80 + i * 20;
        QRect rect(mm, nn, 20, 20);
        Ob9[Ob9.size() - 1 - i] = rect;
    }
    int pp = 140, qq = 420;
    Ob10.resize(10);
    for (int i = 0; i < Ob10.size(); i++)
    {
        qq = 420 + i * 20;
        QRect rect(pp, qq, 20, 20);
        Ob10[Ob10.size() - 1 - i] = rect;
    }
    int cc = 200, dd = 420;
    Ob11.resize(10);
    for (int i = 0; i < Ob11.size(); i++)
    {
        dd = 420 + i * 20;
        QRect rect(cc, dd, 20, 20);
        Ob11[Ob11.size() - 1 - i] = rect;
    }
    int aa = 460, bb = 140;
    Ob12.resize(10);
    for (int i = 0; i < Ob12.size(); i++)
    {
        aa = 460 + i * 20;
        QRect rect(aa, bb, 20, 20);
        Ob12[Ob12.size() - 1 - i] = rect;
    }
    int xx = 460, yy = 240;
    Ob13.resize(10);
    for (int i = 0; i < Ob13.size(); i++)
    {
        xx = 460 + i * 20;
        QRect rect(xx, yy, 20, 20);
        Ob13[Ob13.size() - 1 - i] = rect;
    }
    int ww = 520, vv = 100;
    Ob14.resize(10);
    for (int i = 0; i < Ob14.size(); i++)
    {
        vv = 100 + i * 20;
        QRect rect(ww, vv, 20, 20);
        Ob14[Ob14.size() - 1 - i] = rect;
    }
    int uu = 580, oo = 100;
    Ob15.resize(10);
    for (int i = 0; i < Ob15.size(); i++)
    {
        oo = 100 + i * 20;
        QRect rect(uu, oo, 20, 20);
        Ob15[Ob15.size() - 1 - i] = rect;
    }
}//构图
void paopaotang::uupdate() {
    foreach(int key, keys) {
        switch (key) {
            case Qt::Key_W :
            vperson1.setTop(vperson1.top() - 4);
            vperson1.setBottom(vperson1.bottom() - 4);
            break;
            case Qt::Key_S:
            vperson1.setTop(vperson1.top() + 4);
            vperson1.setBottom(vperson1.bottom() + 4);
            break;
            case Qt::Key_A:
            vperson1.setLeft(vperson1.left() - 4);
            vperson1.setRight(vperson1.right() - 4);
            break;
            case Qt::Key_D:
            vperson1.setLeft(vperson1.left() + 4);
            vperson1.setRight(vperson1.right() + 4);
            break;
            case Qt::Key_Space:
                Initboom1();
            break;
        default:;
        }
        switch (key) {
            case Qt::Key_Up:
            vperson2.setTop(vperson2.top() - 4);
            vperson2.setBottom(vperson2.bottom() - 4);
            break;
            case Qt::Key_Down:
            vperson2.setTop(vperson2.top() + 4);
            vperson2.setBottom(vperson2.bottom() + 4);
            break;
            case Qt::Key_Left:
            vperson2.setLeft(vperson2.left() - 4);
            vperson2.setRight(vperson2.right() - 4);
            break;
            case Qt::Key_Right:
            vperson2.setLeft(vperson2.left() + 4);
            vperson2.setRight(vperson2.right() + 4);
            break;
            case Qt::Key_0:
                Initboom2();
                break;
        default:;
        }
    }
        if (vperson1.right() >740) {
            vperson1.setRight(vperson1.right()-4);
            vperson1.setLeft(vperson1.left()-4) ;
        }
        if (vperson1.bottom()> 740) {
            vperson1.setBottom(vperson1.bottom() -4);
            vperson1.setTop(vperson1.top() - 4);
        }
        if (vperson1.top() < 20) {
            vperson1.setTop(vperson1.top() +4);
            vperson1.setBottom(vperson1.bottom() + 4);
        }
        if (vperson1.left() < 20) {
            vperson1.setLeft(vperson1.left() +4);
            vperson1.setRight(vperson1.right() + 4);
        }
        if (vperson2.right() > 740) {
            vperson2.setRight(vperson2.right() - 4);
            vperson2.setLeft(vperson2.left() - 4);
        }
        if (vperson2.bottom() > 740) {
            vperson2.setBottom(vperson2.bottom() - 4);
            vperson2.setTop(vperson2.top() - 4);
        }
        if (vperson2.top() < 20) {
            vperson2.setTop(vperson2.top() + 4);
            vperson2.setBottom(vperson2.bottom() + 4);
        }
        if (vperson2.left() < 20) {
            vperson2.setLeft(vperson2.left() + 4);
            vperson2.setRight(vperson2.right() + 4);
        }
    update();
}//移动
void paopaotang::disapp1() {
    cz1[0] = false;
    h = false;
    sj1->stop();
}
void paopaotang::disapp2() {
   cz1[1] = false;
   i = false;
   sj2->stop();
}
void paopaotang::disapp3() {
   cz1[2] = false;
   j = false;
   sj3->stop();
}
void paopaotang::disapp4() {
    cz2[0] = false;
    k = false;
    sj4->stop();
}
void paopaotang::disapp5() {
    cz2[1] = false;
    l = false;
    sj5->stop();
}
void paopaotang::disapp6() {
    cz2[2] = false;
    o = false;
    sj6->stop();
}//炸弹消失
void paopaotang::zharen1() {
    h = true;
    int n,m,p,q;
    if ((boom[0].left() >= vperson1.left() && boom[0].left() <= vperson1.right()) || (vperson1.left() >= boom[0].left() && vperson1.left() <= boom[0].right()))
    {
        n = 1;
    }
    else
    {
        n = 0;
    }
    if ((boom[0].top() >= vperson1.top() && boom[0].top() <= vperson1.bottom()) || (vperson1.top() >= boom[0].top() && vperson1.top() <= boom[0].bottom()))
    {
        m = 1;
    }
    else
    {
        m = 0;
    }
    if ((boom[0].left() >= vperson2.left() && boom[0].left() <= vperson2.right()) || (vperson2.left() >= boom[0].left() && vperson2.left() <= boom[0].right()))
    {
        p = 1;
    }
    else
    {
        p = 0;
    }
    if ((boom[0].top() >= vperson2.top() && boom[0].top() <= vperson2.bottom()) || (vperson2.top() >= boom[0].top() && vperson2.top() <= boom[0].bottom()))
    {
        q = 1;
    }
    else
    {
        q = 0;
    }
    if ((n == 1 || m == 1) && (p == 0 && q == 0)) {
        blsover = true;
        Display = "1P Is Over!";
    }
    if ((n == 0 && m == 0) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "2P Is Over";
    }
    if ((n == 1 || m == 1) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "You Are Over Together";
    }
        sjs1->stop();
}
void paopaotang::zharen2() {
    i = true;
    int n, m, p, q;
    if ((boom[1].left() >= vperson1.left() && boom[1].left() <= vperson1.right()) || (vperson1.left() >= boom[1].left() && vperson1.left() <= boom[1].right()))
    {
        n = 1;
    }
    else
    {
        n = 0;
    }
    if ((boom[1].top() >= vperson1.top() && boom[1].top() <= vperson1.bottom()) || (vperson1.top() >= boom[1].top() && vperson1.top() <= boom[1].bottom()))
    {
        m = 1;
    }
    else
    {
        m = 0;
    }
    if ((boom[1].left() >= vperson2.left() && boom[1].left() <= vperson2.right()) || (vperson2.left() >= boom[1].left() && vperson2.left() <= boom[1].right()))
    {
        p = 1;
    }
    else
    {
        p = 0;
    }
    if ((boom[1].top() >= vperson2.top() && boom[1].top() <= vperson2.bottom()) || (vperson2.top() >= boom[1].top() && vperson2.top() <= boom[1].bottom()))
    {
        q = 1;
    }
    else
    {
        q = 0;
    }
    if ((n == 1 || m == 1) && (p == 0 && q == 0)) {
        blsover = true;
        Display = "1P Is Over!";
    }
    if ((n == 0 && m == 0) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "2P Is Over";
    }
    if ((n == 1 || m == 1) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "You Are Over Together";
    }


        sjs2->stop();

}
void paopaotang::zharen3() {
    j = true;
    int n, m, p, q;
    if ((boom[2].left() >= vperson1.left() && boom[2].left() <= vperson1.right()) || (vperson1.left() >= boom[2].left() && vperson1.left() <= boom[2].right()))
    {
        n = 1;
    }
    else
    {
        n = 0;
    }
    if ((boom[2].top() >= vperson1.top() && boom[2].top() <= vperson1.bottom()) || (vperson1.top() >= boom[2].top() && vperson1.top() <= boom[2].bottom()))
    {
        m = 1;
    }
    else
    {
        m = 0;
    }
    if ((boom[2].left() >= vperson2.left() && boom[2].left() <= vperson2.right()) || (vperson2.left() >= boom[2].left() && vperson2.left() <= boom[2].right()))
    {
        p = 1;
    }
    else
    {
        p = 0;
    }
    if ((boom[2].top() >= vperson2.top() && boom[2].top() <= vperson2.bottom()) || (vperson2.top() >= boom[2].top() && vperson2.top() <= boom[2].bottom()))
    {
        q = 1;
    }
    else
    {
        q = 0;
    }
    if ((n == 1 || m == 1) && (p == 0 && q == 0)) {
        blsover = true;
        Display = "1P Is Over!";
    }
    if ((n == 0 && m == 0) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "2P Is Over";
    }
    if ((n == 1 || m == 1) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "You Are Over Together";
    }
        sjs3->stop();

}
void paopaotang::zharen4() {
    k = true;
    int n, m, p, q;
    if ((boom1[0].left() >= vperson1.left() && boom1[0].left() <= vperson1.right()) || (vperson1.left() >= boom1[0].left() && vperson1.left() <= boom1[0].right()))
    {
        n = 1;
    }
    else
    {
        n = 0;
    }
    if ((boom1[0].top() >= vperson1.top() && boom1[0].top() <= vperson1.bottom()) || (vperson1.top() >= boom1[0].top() && vperson1.top() <= boom1[0].bottom()))
    {
        m = 1;
    }
    else
    {
        m = 0;
    }
    if ((boom1[0].left() >= vperson2.left() && boom1[0].left() <= vperson2.right()) || (vperson2.left() >= boom1[0].left() && vperson2.left() <= boom1[0].right()))
    {
        p = 1;
    }
    else
    {
        p = 0;
    }
    if ((boom1[0].top() >= vperson2.top() && boom1[0].top() <= vperson2.bottom()) || (vperson2.top() >= boom1[0].top() && vperson2.top() <= boom1[0].bottom()))
    {
        q = 1;
    }
    else
    {
        q = 0;
    }
    if ((n == 1 || m == 1) && (p == 0 && q == 0)) {
        blsover = true;
        Display = "1P Is Over!";
    }
    if ((n == 0 && m == 0) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "2P Is Over";
    }
    if ((n == 1 || m == 1) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "You Are Over Together";
    }
        sjs4->stop();
}
void paopaotang::zharen5() {
    l = true;
    int n, m, p, q;
    if ((boom1[1].left() >= vperson1.left() && boom1[1].left() <= vperson1.right()) || (vperson1.left() >= boom1[1].left() && vperson1.left() <= boom1[1].right()))
    {
        n = 1;
    }
    else
    {
        n = 0;
    }
    if ((boom1[1].top() >= vperson1.top() && boom1[1].top() <= vperson1.bottom()) || (vperson1.top() >= boom1[1].top() && vperson1.top() <= boom1[1].bottom()))
    {
        m = 1;
    }
    else
    {
        m = 0;
    }
    if ((boom1[1].left() >= vperson2.left() && boom1[1].left() <= vperson2.right()) || (vperson2.left() >= boom1[1].left() && vperson2.left() <= boom1[1].right()))
    {
        p = 1;
    }
    else
    {
        p = 0;
    }
    if ((boom1[1].top() >= vperson2.top() && boom1[1].top() <= vperson2.bottom()) || (vperson2.top() >= boom1[1].top() && vperson2.top() <= boom1[1].bottom()))
    {
        q = 1;
    }
    else
    {
        q = 0;
    }
    if ((n == 1 || m == 1) && (p == 0 && q == 0)) {
        blsover = true;
        Display = "1P Is Over!";
    }
    if ((n == 0 && m == 0) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "2P Is Over";
    }
    if ((n == 1 || m == 1) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "You Are Over Together";
    }
        sjs5->stop();
}
void paopaotang::zharen6() {
    o = true;
    int n, m, p, q;
    if ((boom1[2].left() >= vperson1.left() && boom1[2].left() <= vperson1.right()) || (vperson1.left() >= boom1[2].left() && vperson1.left() <= boom1[2].right()))
    {
        n = 1;
    }
    else
    {
        n = 0;
    }
    if ((boom1[2].top() >= vperson1.top() && boom1[2].top() <= vperson1.bottom()) || (vperson1.top() >= boom1[2].top() && vperson1.top() <= boom1[2].bottom()))
    {
        m = 1;
    }
    else
    {
        m = 0;
    }
    if ((boom1[2].left() >= vperson2.left() && boom1[2].left() <= vperson2.right()) || (vperson2.left() >= boom1[2].left() && vperson2.left() <= boom1[2].right()))
    {
        p = 1;
    }
    else
    {
        p = 0;
    }
    if ((boom1[2].top() >= vperson2.top() && boom1[2].top() <= vperson2.bottom()) || (vperson2.top() >= boom1[2].top() && vperson2.top() <= boom1[2].bottom()))
    {
        q = 1;
    }
    else
    {
        q = 0;
    }
    if ((n == 1 || m == 1) && (p == 0 && q == 0)) {
        blsover = true;
        Display = "1P Is Over!";
    }
    if ((n == 0 && m == 0) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "2P Is Over";
    }
    if ((n == 1 || m == 1) && (p == 1 || q == 1)) {
        blsover = true;
        Display = "You Are Over Together";
    }
        sjs6->stop();
}
void paopaotang::keyPressEvent(QKeyEvent* event)//键盘读取按下
{
    if (!event->isAutoRepeat())
    {
        keys.append(event->key());
    }
}
void paopaotang::keyReleaseEvent(QKeyEvent* event)//键盘读取松开
{
    if (!event->isAutoRepeat())
    {
        keys.removeAll(event->key());
    }
}
